package com.ruoyi.project.system.policy_information.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.policy_information.domain.PolicyInformation;
import com.ruoyi.project.system.policy_information.service.IPolicyInformationService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * policy_informationController
 * 
 * @author admin
 * @date 2025-04-24
 */
@Controller
@RequestMapping("/cross/policy_information")
public class PolicyInformationController extends BaseController
{
    private String prefix = "cross/policy_information";

    @Autowired
    private IPolicyInformationService policyInformationService;

    @RequiresPermissions("cross:policy_information:view")
    @GetMapping()
    public String policy_information()
    {
        return prefix + "/policy_information";
    }

    /**
     * 查询policy_information列表
     */
    @RequiresPermissions("cross:policy_information:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PolicyInformation policyInformation)
    {
        startPage();
        List<PolicyInformation> list = policyInformationService.selectPolicyInformationList(policyInformation);
        return getDataTable(list);
    }

    /**
     * 导出policy_information列表
     */
    @RequiresPermissions("cross:policy_information:export")
    @Log(title = "policy_information", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PolicyInformation policyInformation)
    {
        List<PolicyInformation> list = policyInformationService.selectPolicyInformationList(policyInformation);
        ExcelUtil<PolicyInformation> util = new ExcelUtil<PolicyInformation>(PolicyInformation.class);
        return util.exportExcel(list, "policy_information数据");
    }

    /**
     * 新增policy_information
     */
    @RequiresPermissions("cross:policy_information:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存policy_information
     */
    @RequiresPermissions("cross:policy_information:add")
    @Log(title = "policy_information", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PolicyInformation policyInformation)
    {
        return toAjax(policyInformationService.insertPolicyInformation(policyInformation));
    }

    /**
     * 修改policy_information
     */
    @RequiresPermissions("cross:policy_information:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        PolicyInformation policyInformation = policyInformationService.selectPolicyInformationById(id);
        mmap.put("policyInformation", policyInformation);
        return prefix + "/edit";
    }

    /**
     * 修改保存policy_information
     */
    @RequiresPermissions("cross:policy_information:edit")
    @Log(title = "policy_information", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PolicyInformation policyInformation)
    {
        return toAjax(policyInformationService.updatePolicyInformation(policyInformation));
    }

    /**
     * 删除policy_information
     */
    @RequiresPermissions("cross:policy_information:remove")
    @Log(title = "policy_information", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(policyInformationService.deletePolicyInformationByIds(ids));
    }
}
